package lms.utils;


import lms.entity.Book;
import lms.entity.Reader;
import org.springframework.jdbc.core.RowMapper;

import javax.swing.tree.TreePath;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * @description:
 * @author: Grape_Pip
 * @time: 2021/06/22
 */
public class BookRowMapper implements RowMapper<Book> {

    @Override
    public Book mapRow(ResultSet resultSet, int i) throws SQLException {
        int bid = resultSet.getInt("bISBN");
        String bName = resultSet.getString("bname");
        String bAuthor = resultSet.getString("bauthor");
        int bStocks = resultSet.getInt("bstocks");
        String bPublish = resultSet.getString("bpublish");
        Date bPublishDate = resultSet.getDate("bpublishtime");
        String bType = resultSet.getString("btype");
        Book book = new Book();

        book.setBookISBN(bid);
        book.setBookName(bName);
        book.setBookAuthor(bAuthor);
        book.setBookStock(bStocks);
        book.setBookpublish(bPublish);
        book.setBookPublishDate(bPublishDate);
        book.setBookType(bType);

        return book;
    }
}
